import java.util.Scanner;

public class Test2 {

    public static int test1(int[] num) {
        int max = num[0];
        int maxIndex = 0;
        for (int i = 1; i < num.length; i++) {
            if (max < num[i]) {
                max = num[i];
                maxIndex = i;
            }
        }
        return maxIndex;
    }

    public static int test2(int[] num) {
        int min = num[0];
        int minIndex = 0;
        for (int i = 1; i < num.length; i++) {
            if (min > num[i]) {
                min = num[i];
                minIndex = i;
            }
        }
        return minIndex;
    }

    public static int test3(int[] num, int target) {
        int tarIndex = 0;
        for (int i = 1; i < num.length; i++) {
            if (target == num[i]) {
                tarIndex = i;
            }
        }
        return tarIndex;
    }

    public static int test4(int[] num, int index) {
        return num[index];
    }

    public static boolean test5(int[] num, int pos1, int aimNum) {
        if (pos1 >= 0 && pos1 < num.length) {
            for (int i = num.length - 1; i > pos1; i--) {
                num[i] = num[i - 1];
            }
            num[pos1] = aimNum;
            return true;
        } else {
            return false;
        }
    }

    public static boolean test6(int[] num, int pos2) {
        if (pos2 >= 0 && pos2 < num.length) {
            for (int i = pos2; i < num.length - 1; i++) {
                num[i] = num[i + 1];
            }
            num[num.length - 1] = 0;
            return true;
        } else {
            return false;
        }
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int[] num = {12, 25, 78, 954, 123, 68, 451, 7481, 32, 8};
        // 1
        int num1 = test1(num);
        System.out.println("最大值的下标为:" + num1);
        // 2
        int num2 = test2(num);
        System.out.println("最小值的下标为:" + num2);
        // 3
        System.out.println("请输入指定的元素:");
        int target = input.nextInt();
        int num3 = test3(num,target);
        System.out.println("指定元素的下标为:"+num3);
        // 4
        System.out.println("请输入指定的下标:");
        int index = input.nextInt();
        int num4 = test4(num,index);
        System.out.println("指定下标的元素为:"+num4);
        // 5
        System.out.println("请输入插入数据的下标位置:");
        int pos1 = input.nextInt();
        System.out.println("请输入要插入的数据:");
        int aimNum = input.nextInt();
        if (test5(num, pos1, aimNum)){
            System.out.println("插入成功,结果是:");
            for (int i = 0; i < num.length; i++){
                System.out.println(num[i]);
            }
        }else {
            System.out.println("插入失败");
        }
        //6
        System.out.println("请输入删除数据的下标位置:");
        int pos2 = input.nextInt();
        if (test6(num, pos2)) {
            System.out.println("删除成功,结果是:");
            for (int i = 0; i < num.length; i++) {
                System.out.println(num[i]);
            }
        } else {
            System.out.println("删除失败");
        }
    }
}
